<template>
  <nav>
    <router-link to="/">首页</router-link> |
    <router-link to="/public-activities">公开活动</router-link>
    <span v-if="authStore.isAdmin"> |
      <router-link to="/activity-management">活动管理</router-link>
    </span>
    <span v-if="authStore.isAuthenticated"> |
      <button @click="handleLogout">退出</button>
    </span>
  </nav>
</template>

<script>
import { useAuthStore } from '../stores/auth'
import { useRouter } from 'vue-router'

export default {
  setup() {
    const authStore = useAuthStore()
    const router = useRouter()

    const handleLogout = () => {
      authStore.logout()
      router.push('/login')
    }

    return { authStore, handleLogout }
  }
}
</script>